package com.hualan.sfzy.controller.counselor;

import com.hualan.sfzy.entity.CounselorGrade;
import com.hualan.sfzy.service.counselor.CounselorGradeService;
import com.hualan.sfzy.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/counselorGrade")
public class CounselorGradeController {
   @Autowired
    private CounselorGradeService service;
    @PostMapping
    public Result add(@RequestBody CounselorGrade entity){
       return service.add(entity) > 0 ? Result.success() : Result.error();
    }
    @DeleteMapping("/{id}")
    public Result remove(@PathVariable Integer id){
        return service.remove(id) > 0 ? Result.success() : Result.error();
    }
    @DeleteMapping
    public Result removeBatch(Integer[] ids){
        return service.removeBatch(ids) > 0 ? Result.success() : Result.error();
    }
    @PutMapping
    public Result edit(@RequestBody CounselorGrade entity){
        return service.edit(entity) > 0 ? Result.success() : Result.error();
    }
    @GetMapping("/{id}")
    public Result findById(@PathVariable Integer id){
        return Result.success(service.findById(id));
    }
    @GetMapping
    public Result find(){
        return Result.success(service.find());
    }
    @GetMapping("/page")
    public Result findPage(@RequestParam(value = "pageNum",required = false, defaultValue = "1")Integer pageNum,
                                        @RequestParam(value = "pageSize",required = false, defaultValue = "10")Integer pageSize, CounselorGrade entity){
        return Result.success(service.findPage(pageNum, pageSize, entity));
    }
}
